package com.phone.handle;

import com.phone.entity.Cash;
import com.phone.entity.CashHistory;
import com.phone.exception.ErrorOwneridException;
import com.phone.exception.NoBindingIdException;
import com.phone.exception.NotSufficientMoneyException;
import com.phone.utils.TextUtil;
import org.hibernate.Session;

import java.util.Date;
import java.util.List;

/**
 * Created by tisen on 2017/7/6.
 */
public class CashHandle extends EntityHandle<CashHistory> {
    public CashHandle(Session session) {
        super(session);
    }

    @Override
    public void update(CashHistory cashHistory) throws Exception {
        CashHistory cashHistory1 = get(cashHistory.getId());
        if (cashHistory.isComplete()) {
            cashHistory1.setComplete(true);
            cashHistory.setCompleteDate(new Date());
            super.update(cashHistory1);
        } else {

        }
    }

    public void complete(String id) throws Exception {
        CashHistory cashHistory = get(id);
        cashHistory.setComplete(true);
        cashHistory.setCompleteDate(new Date());
        super.update(cashHistory);
    }

    @Override
    public void update(String id, CashHistory cashHistory) throws Exception {
        CashHistory cashHistory1 = get(id);
        super.update(id, cashHistory1);
    }
}
